package com.mlz.mlzmall.custom;

import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.util.Log;
import android.webkit.WebView;
import android.widget.Toast;

import com.mlz.mlzmall.ui.utils.util.LogUtils;

/**
 * describe :
 * Created by Pm on 2016/6/8.
 * PackageName com.mlz.mlzmall.custom.
 * ProjectName mlzmall_android.
 */

public class ArticleWebView extends WebView {
    private OnLoadFinishListener mOnLoadFinishListener;
    public interface OnLoadFinishListener{
        public void onLoadFinish();
    }
    private boolean isRendered = false;
    public ArticleWebView(Context context) {
        super(context);
        init();
    }
    public ArticleWebView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }
    public ArticleWebView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }
    private void init(){
    }
    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        if(!isRendered){
          //  DebugLog.log("ArticleWebView", "getContentHeight():"+getContentHeight());
         //   LogUtils.d("getContentHeight"+getContentHeight());
            Log.e("getContentHeight",getContentHeight()+"");
            isRendered = getContentHeight() >0;
            if(mOnLoadFinishListener!= null){
                mOnLoadFinishListener.onLoadFinish();
            }
        }
    }
    public void setOnLoadFinishListener(OnLoadFinishListener onLoadFinishListener){
        this.mOnLoadFinishListener = onLoadFinishListener;
    }
}
